#!/usr/bin/perl -w

@P=qw(/usr/bin /usr/sbin /usr/local/bin /bin /sbin);

$VIRSH=undef;
for (@P) {
	if(-f "$_/virsh" && -x _) {
		$VIRSH="$_/virsh";last;
	}
}

if(!defined($VIRSH)) {
	print STDERR "virsh executable not found.\n";
	exit(1);
}

$machine=$ARGV[0];
$r=`$VIRSH start $machine 2>&1`;
if($?>>8) {
	my ($rr)=($r =~ /error: (.*)$/m); chomp $rr; 
	print STDERR "ERROR: $rr\n";
	exit(1);
}
exit(0);

